package com.ruoyi.web.controller.platform;
import java.util.List;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.platform.service.IMWarningService;
import com.ruoyi.platform.vo.request.WarningReportRequest;
import com.ruoyi.platform.vo.response.WarningReportVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/platform/warn-report")
public class WarningReportController extends BaseController
{
    @Autowired
    private IMWarningService imWarningService;

    /**
     * 查询【预警台账】列表
     */
    @PreAuthorize("@ss.hasPermi('platform:warningReport:list')")
    @GetMapping("/list")
    public TableDataInfo list(WarningReportRequest reportRequest)
    {
        startPage();
        List<WarningReportVo> list = imWarningService.queryWarningReports(reportRequest);
        return getDataTable(list);
    }

    /**
     * 导出【预警台账】列表
     */
    @PreAuthorize("@ss.hasPermi('platform:warningReport:export')")
    @Log(title = "导出预警台账列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WarningReportRequest reportRequest)
    {
        List<WarningReportVo> list = imWarningService.queryWarningReports(reportRequest);
        ExcelUtil<WarningReportVo> util = new ExcelUtil<WarningReportVo>(WarningReportVo.class);
        util.exportExcel(response, list, "预警台账数据");
    }

    /**
     * 获取【预警信息】详细信息
     */
    @PreAuthorize("@ss.hasPermi('platform:warningReport:query')")
    @GetMapping(value = "/{warningId}")
    public AjaxResult getInfo(@PathVariable("warningId") String warningId)
    {
        return success(imWarningService.queryReportDetailsByWarningId(warningId));
    }
}
